//
//  UserCenterCell.m
//  JinMaJiaDemo
//
//  Created by GripMeMory on 15/10/12.
//  Copyright © 2015年 GripMeMory. All rights reserved.
//

#import "UserCenterCell.h"
#import "UserCenterData.h"
#import "UIView+Sizes.h"

#define kImageViewLeftMargin 15
#define kImageViewWidth 65 / 2

#define kTitleLabelLeftMargin 15
#define kTitleLabelWidth 150

@interface UserCenterCell ()

{
    UIImageView *imageView;
    UILabel *titleLable;
}

@end

@implementation UserCenterCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        imageView = [[UIImageView alloc] init];
        titleLable = [[UILabel alloc] init];
        [self.contentView addSubview:imageView];
        [self.contentView addSubview:titleLable];
    }
    return self;
}

- (void)layoutSubviews{
    imageView.frame = CGRectMake(kImageViewLeftMargin, (self.height - kImageViewWidth) / 2, kImageViewWidth, kImageViewWidth);
    UIImage *image = [UIImage imageNamed:@"bg.jpg"];
    imageView.image = image;
    imageView.layer.cornerRadius = 5;
    imageView.layer.borderWidth = 3;
    imageView.clipsToBounds = YES;
    
    titleLable.frame = CGRectMake(imageView.right + kTitleLabelLeftMargin, imageView.top, kTitleLabelWidth, kImageViewWidth);
    titleLable.textAlignment = NSTextAlignmentLeft;
}

- (void)configureCellWithModel:(id)model{
    UserCenterData *data = model;
    titleLable.text = data.titleName;
}

- (void)configureImageViewBorderColorWithIndexPath:(NSIndexPath *)indexPath{
    int flag = indexPath.row % 2;
    if (flag == 0) {
        imageView.layer.borderColor = [RGB_COLOR(@"#d20000") CGColor];
    }else{
        imageView.layer.borderColor = [RGB_COLOR(@"#c9c900") CGColor];
    }
}

@end
